﻿using BBICMS.Infrastructure.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BBICMS.Model.View
{
    public class AdListVM
    {
        public IEnumerable<Advertisement> Advertisements { get; set; }
        public PagingInfo PagingInfo { get; set; }
        public string AdsJSON
        {
            get
            {
                JsonSerializerSettings settings =
                    new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    };

                settings.ContractResolver =
                    new CamelCasePropertyNamesContractResolver();

                var ads = JsonConvert.SerializeObject(this.Advertisements, settings);
                return ads;
            }
        }
    }
}
